﻿// Decompiled with JetBrains decompiler
// Type: MCM.Abstractions.BaseSettingsExtensions
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using BUTR.DependencyInjection;
using MCM.Abstractions.Base;
using MCM.Abstractions.Properties;
using System;
using System.Collections.Generic;
using System.Linq;

#nullable enable
namespace MCM.Abstractions
{
  public static class BaseSettingsExtensions
  {
    public static List<SettingsPropertyGroupDefinition> GetSettingPropertyGroups(
      this BaseSettings settings)
    {
      return settings.GetUnsortedSettingPropertyGroups().SortDefault().ToList<SettingsPropertyGroupDefinition>();
    }

    public static IEnumerable<SettingsPropertyGroupDefinition> GetUnsortedSettingPropertyGroups(
      this BaseSettings settings)
    {
      ISettingsPropertyDiscoverer propertyDiscoverer = ((IEnumerable<ISettingsPropertyDiscoverer>) ((object) GenericServiceProvider.GetService<IEnumerable<ISettingsPropertyDiscoverer>>() ?? (object) Array.Empty<ISettingsPropertyDiscoverer>())).FirstOrDefault<ISettingsPropertyDiscoverer>((Func<ISettingsPropertyDiscoverer, bool>) (x => x.DiscoveryTypes.Any<string>((Func<string, bool>) (y => y == settings.DiscoveryType))));
      return (IEnumerable<SettingsPropertyGroupDefinition>) SettingsUtils.GetSettingsPropertyGroups(settings.SubGroupDelimiter, (IEnumerable<ISettingsPropertyDefinition>) ((propertyDiscoverer != null ? (object) propertyDiscoverer.GetProperties(settings) : (object) null) ?? (object) Array.Empty<ISettingsPropertyDefinition>()));
    }

    public static IEnumerable<ISettingsPropertyDefinition> GetAllSettingPropertyDefinitions(
      this BaseSettings settings)
    {
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      return settings.GetSettingPropertyGroups().SelectMany<SettingsPropertyGroupDefinition, ISettingsPropertyDefinition>(BaseSettingsExtensions.\u003C\u003EO.\u003C0\u003E__GetAllSettingPropertyDefinitions ?? (BaseSettingsExtensions.\u003C\u003EO.\u003C0\u003E__GetAllSettingPropertyDefinitions = new Func<SettingsPropertyGroupDefinition, IEnumerable<ISettingsPropertyDefinition>>(SettingsUtils.GetAllSettingPropertyDefinitions)));
    }

    public static IEnumerable<SettingsPropertyGroupDefinition> GetAllSettingPropertyGroupDefinitions(
      this BaseSettings settings)
    {
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      return settings.GetSettingPropertyGroups().SelectMany<SettingsPropertyGroupDefinition, SettingsPropertyGroupDefinition>(BaseSettingsExtensions.\u003C\u003EO.\u003C1\u003E__GetAllSettingPropertyGroupDefinitions ?? (BaseSettingsExtensions.\u003C\u003EO.\u003C1\u003E__GetAllSettingPropertyGroupDefinitions = new Func<SettingsPropertyGroupDefinition, IEnumerable<SettingsPropertyGroupDefinition>>(SettingsUtils.GetAllSettingPropertyGroupDefinitions)));
    }

    public static IEnumerable<ISettingsPreset> GetExternalPresets(this BaseSettings settings)
    {
      return GenericServiceProvider.GetService<BaseSettingsProvider>()?.GetPresets(settings.Id) ?? (IEnumerable<ISettingsPreset>) Array.Empty<ISettingsPreset>();
    }
  }
}
